package logic

import (
	"context"
	"user_srv/model/mysql"

	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetUserInfoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserInfoLogic {
	return &GetUserInfoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 获取用户信息

func (l *GetUserInfoLogic) GetUserInfo(in *user.GetUserInfoByUsernameRequest) (*user.GetUserInfoByUsernameResponse, error) {
	// todo: add your logic here and delete this line
	u := mysql.User{}
	/*_ := u.GetUserInfoUsername(in.Username)
	if err != nil {
		return nil, err
	}
	if err != nil {
		logx.Error("获取用户信息失败:", err)
		return nil, err
	}*/
	username := u.GetUserInfoUsername(in.Username)

	return &user.GetUserInfoByUsernameResponse{UserId: int64(username.ID),
		Username: username.Username,
		Password: username.Password,
		Salt:     username.Salt,
	}, nil
}
